package com.sunjob.mroresumeproject.dao;

import com.sunjob.common.domain.mroresume.RPBus;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface RPBusMapper {

    @Select("select count(*) from rp_busresume where status=1 and types=#{types}")
    int querycount(String types);

    @Select("select repairid,fault,bustypes,management,RPstate from rp_busresume  where status=1 and types limit #{pages},#{size}")
    List<RPBus> queryrepair(int pages, int size,String types);

    @Select("select repairid,fault,bustypes,management,RPstate from rp_busresume where repairid=#{repairid}  and status=1")
    @Results({
            @Result(property = "repairid",column = "repairid"),
            @Result(property = "fault",column = "fault"),
            @Result(property = "bustypes",column = "bustypes"),
            @Result(property = "management",column = "management"),
            @Result(property = "RPstate",column = "RPstate"),
    })
    List<RPBus> queryrepair2(String repairid);


    @Insert("insert into rp_busresume values(repairid,types,bustypes,Use_parts,management,fault,RPstate,failreason,money,starttime,endtime,status)")
    void insertrepair(RPBus rpBus);



    @Select("select repairid,fault,bustypes,management,RPstate from rp_busresume where repairid=#{repairid} and status=1")
    @Results({
            @Result(property = "repairid",column = "repairid"),
            @Result(property = "fault",column = "fault"),
            @Result(property = "bustypes",column = "bustypes"),
            @Result(property = "management",column = "management"),
            @Result(property = "RPstate",column = "RPstate"),
    })
    List<RPBus> queryrepairone(Long repairid);

    @Update("update rp_busresume set types=#{types},bustypes=#{bustypes},Use_parts=#{useparts},management=#{management},fault=#{fault},RPstate=#{RPstate},failreason=#{failreason},money=#{money} where repairid=#{repairid}")
    void updaterepair(RPBus rpBus);

    @Update("update rp_busresume set statues=0 where repairid=#{repairid}")
    void deleterepair(String repairid);

    @Update("update rp_busresume set statues=0 where repairid=#{s}")
    void deleterepairone(String s);
}
